package com.my.zidingyikongjian.view.one;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.view.View;

/**
 * 项目名称：多条线
 * 创建人：mwb
 * 创建时间：2018/6/28 10:03
 */

public class MoreLineView extends View {

    public MoreLineView(Context context) {
        super(context);
    }

    @Override
    protected void onDraw(Canvas canvas) {
        super.onDraw(canvas);

        Paint paint = new Paint();
        paint.setStrokeWidth(5); // 画笔大小
        paint.setStyle(Paint.Style.FILL); // 画笔填充
        paint.setColor(Color.RED);

        canvas.drawRGB(255, 255, 255);
        // 画线的集合(float型) 规则 {x1,y1,x2,y2,x3,y3...}
        float[] pts = {10, 10, 100, 100, 200, 200, 400, 400}; // 一共四个点 两个点之间连成一条线1-2 但是 2 不连接3-4
        canvas.drawLines(pts, paint);
    }
}
